<template>
	<div>
		<p>localstorage模块</p>
		<input type="text" v-model="nm" placeholder="username">
		<x-button @click.native="evt_setLocal" :mini="true">设置本地存储</x-button>
		<x-button @click.native="evt_removeLocal" :mini="true">注销本地存储信息</x-button>
		<span>{{localuInfo}}</span>
	</div>
</template>
<script type="text/javascript">
	import Vue from 'vue'
	import { XButton } from 'vux'
	import storage from '@/localstorage/conf'
	let storeKey = storage.test;
	export default {
		name: 'demo-local',
		data: () => {
			return {
				nm: '',
				localuInfo: null
			}
		},
		mounted() {
			this.localuInfo = Vue.ls.get(storeKey);
		},
		methods: {
			evt_setLocal() {
				Vue.ls.set(storeKey, {token: this.nm}, 60 * 60 * 1000);
				this.localuInfo = Vue.ls.get(storeKey);
			},
			evt_removeLocal() {
				Vue.ls.remove(storeKey);
				this.localuInfo = Vue.ls.get(storeKey);
			}
		},
		components: {
			XButton
		}
	}
</script>